Skip to content

Follow the project directory a push renames in cloud commands - #734

Merged
quantconnect-kronos[bot] merged 3 commits into
masterfrom
kronos/bug-721-follow-renamed-pushed-project
Nov 17, 2026
Merged

quantconnect-kronos[bot] merged 3 commits into
masterfrom
kronos/bug-721-follow-renamed-pushed-project

Conversation

@quantconnect-kronos

@quantconnect-kronos quantconnect-kronos Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Closes #721

What changed and why

lean cloud <command> <project> --push pushes the local project, then reads its config.json to get the cloud id. When the push renames the project directory, the resolver still read the old path. This happens when the name isn't valid locally (for example Unsafe:Project becomes Unsafe Project) or when the cloud assigns a different name. The resolver found no cloud id and raised, and lean cloud backtest reported that the project wasn't found, even though the push had succeeded.

  • PushManager._push_project now returns the path where the project is after the push. The recursive call for a cloud-assigned name passes that path through.
  • PushManager.push_projects records each pushed project's final path in pushed_project_paths, keyed by the path it was given. Its return value is unchanged.
  • CloudProjectManager.get_cloud_project reads the cloud id from the recorded final path.

The resolver doesn't search the workspace or write a local id. Other project configs are never touched, and a copy that shares its original's local-id resolves to its own cloud project. A linked project in a read-only directory pushes the way it does on master. Pushes that don't rename work as before.

The first commit found the project by its local id instead. Review showed that this rewrote other configs it couldn't parse, could pick a copy's original, and broke read-only pushes. The second commit replaces it.

Tests

New tests in tests/components/cloud/test_cloud_project_manager.py use the real push manager and project config manager with a mocked API:

  • test_get_cloud_project_follows_project_renamed_by_push: a sanitized name (Unsafe:Project) and a replacement name assigned by the cloud. Both fail on master.
  • test_get_cloud_project_leaves_other_project_configs_untouched_when_push_renames_project: a sibling config.json holding JSON with a comment stays byte for byte the same.
  • test_get_cloud_project_returns_pushed_copy_sharing_the_local_id_of_its_original: the copy's new cloud project is returned, not the original's.
  • test_get_cloud_project_pushes_read_only_linked_project_without_local_id: the push succeeds as a non-root user with a read-only project directory, and no local-id is written.

On master, the two rename cases, the sibling-config test and the copy test fail; the read-only test passes. On the first commit of this PR, the last three fail. All of them pass now.

  • PYTHONPATH=$PWD python -m pytest -q, rebased on current master: 2836 passed, 81 skipped.
  • python static_analysis.py: build passed, with the 5 unused-import warnings that master already has.
  • Tested end to end:
    • lean cloud backtest "<name with :>" --push renamed the directory, created the cloud project, then compiled and backtested it. On master it stops after the push with No project with the given name or id ... found.
    • A copy named Copy:721, with the same local-id as its pushed original, its cloud-id removed and starting cash changed to 200,000, was pushed and backtested with --push. The backtest ran the copy (start equity 200,000), and a sibling Other App/config.json containing a comment was left unchanged.

@quantconnect-kronos quantconnect-kronos Bot added kronos:develop:working develop: in progress kronos:review Request review labels Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 17, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 17, 2026 15:32

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. The change fixes what #721 asks for and leaves paths the push doesn't rename as they were.

What I checked

  • get_cloud_project now reads the local id before pushing. If the old directory is gone afterwards, it finds the project with ProjectManager.get_project_by_id. A rename only happens in PushManager._push_project: a sanitized local name, or a replacement name from the cloud through its recursive call. That moves the whole directory with its config.json, so the local id goes with it. Paths the push doesn't rename don't run the new lookup.
  • The second push in this method, for input that names a cloud project, pushes to the path get_local_project_path already computed for that project, so the push doesn't rename it. It then reads the project by cloud id, not by path, so it doesn't have this bug. lean cloud push doesn't read the project path after pushing.
  • get_project_by_id searches the CLI root breadth-first and stops at project directories. A project at the top level is found before the search goes deeper into large folders such as data/. The lookup runs only after a rename.
  • Assigning a local-id before the push only adds that key to a config that lacks one. The push already does this for projects without a cloud id, and the local commands do it too.

Evidence

  • The new parametrized test fails on master's cloud_project_manager.py and passes with this change. The file's other tests still pass.
  • CI is green on the head commit.
  • I tested it end to end myself:
    • lean cloud backtest "<name with :>" --push on a new project renamed the directory, created the cloud project, compiled it and ran the backtest to completion.
    • The same command on a project that already had a cloud id, after renaming it to an invalid name, renamed it locally and in the cloud, then backtested.
    • A plain --push with no rename still backtests.

Other repositories: none need an update.

Risk: risk:low. It's a 5-line bug fix that's easy to revert. Paths without a rename are unchanged, and the change is backed by a regression test that fails without it, green CI and end-to-end runs.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk and removed kronos:review:working review: in progress labels Nov 17, 2026
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued and removed kronos:review Request review labels Nov 17, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress risk:high High risk and removed kronos:review:queued review: queued risk:low Low risk labels Nov 17, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes at 591e2db. The normal rename cases are fixed, but recovering the pushed project through a local-ID write and a workspace-wide lookup introduces a blocking correctness/data-preservation problem.

Blocking finding

Please retain the final project path or cloud identity already known by the push instead of rediscovering it through get_project_by_id. I verified three consequences of the current approach:

  • Unrelated configuration loss: with Group/Unsafe:Project and a sibling OtherApp/config.json containing JSON with a comment, lean cloud backtest 'Group/Unsafe:Project' --push uploads and backtests successfully, but replaces the sibling configuration with an object containing only local-id.
  • Wrong algorithm selected: copying an existing project, retaining its local-id, removing its cloud-id, and pushing the copy as Group/Unsafe:Copy creates the correct new cloud project, then compiles and backtests the original project. Tested end to end: the copy specified starting cash of 200,000, but the backtest ran the original with 100,000 and exited 0.
  • Previously working read-only push fails: an already-linked project with no local-id and a read-only project directory pushes successfully on the base branch. This change raises PermissionError creating config.json.lock before uploading.

The first two were reproduced end to end. All three were also compared using the real filesystem and real managers with only the API mocked: the base resolver preserves the unrelated configuration and stops instead of running the wrong project; its read-only push succeeds. Add regression coverage for these cases with the bounded identity-preserving fix.

Other verification

  • CI is green on the reviewed head.
  • Full suite, with the source checkout inherited by subprocesses: PYTHONPATH="$PWD" python -m pytest -q — 2828 passed, 81 skipped.
  • Targeted resolver, project/push manager and cloud-command tests — 237 passed, 3 skipped.
  • Both new rename cases fail with the base resolver and pass with this change.
  • python static_analysis.py — BUILD PASSED, five existing unused-import warnings.
  • The ordinary sanitized-name push, compilation and backtest also pass end to end.

Other repositories: none need an update.

Risk: risk:high, replacing risk:low, because the new recovery path can destroy unrelated configuration and select a different algorithm for execution. Green CI does not cover these reproduced failures.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 17, 2026
@quantconnect-kronos

Copy link
Copy Markdown
Contributor Author

Addressed the requested changes in f7e6a66. The resolver no longer looks the project up by local id, and it doesn't write a local-id before pushing. PushManager._push_project returns the project's final path, push_projects records it in pushed_project_paths, and get_cloud_project reads the cloud id from that path. Added regression tests for each case you raised:

  • a sibling config with a comment stays unchanged
  • a copy that shares its original's local-id resolves to its own cloud project
  • a read-only linked project without a local-id pushes as a non-root user

The first two fail on 591e2db and on master. The read-only one fails on 591e2db and passes on master. The full suite passes (2831 passed, 81 skipped). Tested end to end: the copy case backtested the copy itself (start equity 200,000) and left the sibling config untouched. The description has the details.

@quantconnect-kronos
quantconnect-kronos Bot marked this pull request as draft November 17, 2026 16:04
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 17, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 17, 2026 16:45

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving f7e6a66. My earlier approval of 591e2db missed what the other review found: the local-id lookup could rewrite unrelated configs, pick a copy's original, and break read-only pushes. This commit drops that approach for the smaller one that review asked for: the push reports where the project ended up, and the resolver reads the cloud id from there. This resolves all three problems.

What I checked

  • _push_project returns the final path on every successful exit: the normal end, after a local rename, and through the recursive call when the cloud assigns another name. Every other exit raises.
  • get_cloud_project reads pushed_project_paths[local_path] only when push_projects returned True. That only happens when every entry pushed, so the key is always set by this call, and it's the same Path object the call passed in. An old entry from an earlier push is overwritten before it can be read.
  • The resolver no longer writes a local-id and no longer searches the workspace. The second --push branch, for input that names a cloud project, reads by cloud id and is unchanged. lean cloud push ignores the new dict. The extra cost is one dict entry per pushed project.

Evidence

  • CI is green on the head commit (Build and Regression Testing).
  • The new tests fail where they should. With the PR's test module on master's code, the two rename cases, the sibling-config case and the copy case fail, and they pass here. The read-only test passes on both, as the description says.
  • Full suite on the head merged with current master: 2836 passed, 81 skipped.
  • I tested it end to end myself with the PR's CLI:
    • I copied a pushed project to Kr734:Copy with the same local-id, removed its cloud-id and set its cash to 200,000. I also added a sibling Other App/config.json containing a comment. lean cloud backtest "Kr734:Copy" --push renamed it to Kr734 Copy and created a new cloud project. It backtested the copy itself (start equity 200,000), and the sibling config was byte-for-byte unchanged.
    • A plain --push with no rename still backtests (start equity 100,000).

Non-blocking: master now imports encryption_helper in tests/conftest.py (#735), so the same import in this test module is redundant (inline).

Other repositories: none need an update.

Risk: risk:low. It's a ~10-line fix confined to the push path, easy to revert, and pushes that don't rename work as before. The earlier risk:high was set on 591e2db for the workspace search, which this commit removes. The evidence is regression tests that fail without the fix, green CI and the end-to-end runs above.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added risk:low Low risk and removed risk:high High risk labels Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot removed the kronos:review:working review: in progress label Nov 17, 2026
quantconnect-kronos Bot and others added 3 commits November 17, 2026 16:48
A push renames the local project directory when its name is not valid
or when the cloud assigns a different name. The cloud project resolver
then read config.json from the old path, found no cloud id and failed,
so `lean cloud backtest <name> --push` reported the project as missing.
Find the project by its local id after the push when the directory moved.

Closes #721

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… for it

Looking the project up by local id after the push walked the whole CLI
root, rewrote other configs it couldn't parse, could return another
project sharing the same local id, and wrote a local id before pushing,
which failed for read-only projects. The push now records where each
pushed project ends up and the resolver reads the cloud id from there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@quantconnect-kronos
quantconnect-kronos Bot force-pushed the kronos/bug-721-follow-renamed-pushed-project branch from f7e6a66 to 9ff4ab2 Compare November 17, 2026 16:50
@quantconnect-kronos
quantconnect-kronos Bot marked this pull request as draft November 17, 2026 16:50
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued kronos:review:working review: in progress and removed kronos:review Request review kronos:review:queued review: queued labels Nov 17, 2026
@quantconnect-kronos-reviewer
quantconnect-kronos-reviewer Bot marked this pull request as ready for review November 17, 2026 17:35

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving 9ff4ab2. Since my approval of f7e6a66, the branch was rebased onto master and one commit was added. That commit removes the redundant encryption_helper import from the test module, which was my only open point. tests/conftest.py on master now imports it before every module. lean/ is identical to f7e6a66, so my findings from that review still hold. The push records each project's final path, and the resolver reads the cloud id from it. Nothing searches the workspace or writes a local-id, which resolves all three problems raised on 591e2db.

Evidence

  • CI is green on the head commit.
  • The head merges cleanly with current master.
  • The cloud component and command tests pass on the head: 169 passed.
  • The end-to-end runs from my previous review still apply: the code they ran is unchanged.

Other repositories: none need an update.

Risk: risk:low, unchanged. It's a ~10-line fix confined to the push path and easy to revert. Pushes that don't rename work as before. It's backed by regression tests that fail without the fix, green CI and end-to-end runs.

@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot removed the kronos:review:working review: in progress label Nov 17, 2026
@quantconnect-kronos quantconnect-kronos Bot added the kronos:review Request review label Nov 17, 2026
@quantconnect-kronos-reviewer quantconnect-kronos-reviewer Bot added kronos:review:queued review: queued and removed kronos:review Request review labels Nov 17, 2026
@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot added kronos:review:working review: in progress and removed kronos:review:queued review: queued labels Nov 17, 2026

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 9ff4ab2. The revised approach resolves my earlier blocking finding: it carries the actual final path out of the push instead of writing a local ID and searching the workspace. No new blocking findings.

What I verified

  • _push_project returns the final path after uploading, including through the recursive cloud-assigned rename. push_projects records it under the original input path only after success. The resolver reads that entry only after a successful singleton push, so neither failed pushes nor entries from earlier calls can supply a stale result.
  • The resolver no longer scans unrelated configurations or adds a local ID before pushing. The tests cover configuration preservation, copies sharing a local ID, and read-only linked projects. Existing failure handling and the cloud-ID resolver branch are unchanged.

Evidence

  • Head CI: Build and Regression Testing succeeded.
  • PYTHONPATH="$PWD" python -m pytest -q: 2836 passed, 81 skipped.
  • Running the PR's resolver test module against current master produces 4 failures, 4 passes: both rename cases, configuration-preservation and copied-project resolution fail without the fix; the read-only case passes on both.
  • python static_analysis.py: BUILD PASSED, with the five existing unused-import warnings.
  • Tested end to end: a renamed copy sharing its original's local ID backtested its own code with 200,000 start equity. The original's configuration and an unrelated sibling configuration containing a comment remained byte-for-byte unchanged. An ordinary non-renaming --push also compiled and backtested successfully, with 100,000 start equity.

Other repositories: none need an update.

Risk: risk:low retained. This is a small, reversible fix confined to retaining the successful push's final path. It removes the previously reported configuration-loss/wrong-project recovery mechanism, leaves ordinary pushes unchanged, and is backed by regression tests, green CI and end-to-end verification.

@quantconnect-kronos-reviewer-2 quantconnect-kronos-reviewer-2 Bot removed the kronos:review:working review: in progress label Nov 17, 2026
@quantconnect-kronos
quantconnect-kronos Bot merged commit 1c919ea into master Nov 17, 2026
60 checks passed
@quantconnect-kronos
quantconnect-kronos Bot deleted the kronos/bug-721-follow-renamed-pushed-project branch November 17, 2026 17:50
@quantconnect-kronos quantconnect-kronos Bot removed the kronos:develop:working develop: in progress label Nov 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:low Low risk

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Successful push-induced rename makes cloud backtest report project missing

0 participants